package com.meeting.vo;

import lombok.Data;

/**
 * 通用返回结果封装类
 */
@Data
public class Result1<T> {
    private Integer code;
    private String msg;
    private T data;

    public static final int SUCCESS_CODE = 200;
    public static final int ERROR_CODE = 500;

    private Result1(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result1<T> success(T data) {
        return new Result1<>(SUCCESS_CODE, "success", data);
    }

    public static Result1<Void> success() {
        return new Result1<>(SUCCESS_CODE, "success", null);
    }

    public static Result1<Void> error(String msg) {
        return new Result1<>(ERROR_CODE, msg, null);
    }

    public static Result1<Void> error(int code, String msg) {
        return new Result1<>(code, msg, null);
    }
}